﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace Zocono.WCS.Domain.EquipmentProcessDomain.PlanarGeneralMessage
{
    /// <summary>
    /// 平面通用Plc动作流程服务工厂
    /// </summary>
    public class PlanarGeneralPlcActionProcessServiceFactory : IPlanarGeneralPlcActionProcessServiceFactory
    {
        private readonly IEnumerable<IPlanarGeneralPlcActionProcessService> _services;

        public PlanarGeneralPlcActionProcessServiceFactory(IEnumerable<IPlanarGeneralPlcActionProcessService> services)
        {
            _services = services;
        }
        public IPlanarGeneralPlcActionProcessService Create(string serviceName)
        {
            //var type = Assembly.GetAssembly(typeof(PlanarMessageServiceFactory)).GetType($"Zocono.WCS.Domain.EquipmentProcessDomain.PlanarGeneralMessage.{planarGeneralPlcActionProcessServiceName}");
            //var instance = _provider.GetService(type);
            //return instance as IPlanarGeneralPlcActionProcessService;

            var instance = _services.SingleOrDefault(s => s.GetType().Name == serviceName);
            return instance;
        }
    }
}
